/**
 * JSP项目组版权所有2009
 * 
 */
package cn.com.change.model;

import java.io.Serializable;

import javax.annotation.Generated;
import javax.persistence.Column;
import javax.persistence.Embedded;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;

import org.apache.commons.lang.builder.EqualsBuilder;
import org.apache.commons.lang.builder.ToStringBuilder;

/**
 * @author <a href="mailto:K.Cancer.2007@gmail.com">Rita Liang</a>
 *
 */
@Entity
@Table(name = "cha_school")
public class School extends BaseObject implements Serializable {
	
	private static final long serialVersionUID = -5025662022006719757L;
	private Long id;
	private String name;
	private Address address = new Address();

	@Id
	@GeneratedValue(strategy = GenerationType.AUTO)
	public Long getId() {
		return id;
	}

	@Column(nullable = false)
	public String getName() {
		return name;
	}

	@Embedded
	@Column(nullable = false)
	public Address getAddress() {
		return address;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public void setName(String name) {
		this.name = name;
	}

	public void setAddress(Address address) {
		this.address = address;
	}

	@Override
	public boolean equals(Object o) {
		if(!(o instanceof School)){
			return false;
		}
		School school = (School) o;
		
		return new EqualsBuilder().append(
				this.address,school.address).append(
						this.name, school.name).isEquals();
	}

	@Override
	public int hashCode() {
		return this.name.hashCode();
	}

	@Override
	public String toString() {
		return new ToStringBuilder(this).append(
				"name",name).append(
				"address",address).toString();
	}

}
